<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<jsp:include page="/admin/jsp/common/HtmlHead.jsp"/>
<title>Insert title here</title>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/swfupload/swfupload.js"></script>
<script type="text/javascript">
function fileDialogComplete(numFilesSelected, numFilesQueued) {
	try {
		this.startUpload();
	} catch (ex)  {
        this.debug(ex);
	}
}
function uploadProgress(file,complete,total){
	var bar = document.getElementById('progressBar1');
	var per = parseInt((complete/total)*100)+"%";
	bar.style.width = per;
	bar.innerText = per;
}
function uploadError(file,code,message){
	switch (code) {
	case SWFUpload.UPLOAD_ERROR.HTTP_ERROR:
		alert('Http错误');
		break;
	case SWFUpload.UPLOAD_ERROR.MISSING_UPLOAD_URL:
		alert('找不到上传地址');
		break;
	case SWFUpload.UPLOAD_ERROR.IO_ERROR:
		alert('IO错误');
		break;
	case SWFUpload.UPLOAD_ERROR.SECURITY_ERROR:
		alert('安全错误');
		break;
	case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED:
		//alert('文件大小超出限制范围');
		break;
	case SWFUpload.UPLOAD_ERROR.SPECIFIED_FILE_ID_NOT_FOUND:
		alert('未找到文件ID');
		break;
	case SWFUpload.UPLOAD_ERROR.FILE_VALIDATION_FAILED:
		alert('文件审定失败');
		break;
	case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED:
		alert('用户取消上传');
		break;
	case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED:
		alert('暂停');
		break;
	default:
		alert('上传出错')
		break;
	}
}
function uploadSuccess(file,data){
	alert(data);
}
var swfu;
window.onload=function(){
	swfu = new SWFUpload({
		upload_url : "<s:url action="upload"/>",
		flash_url : "<%=request.getContextPath()%>/js/swfupload/swfupload.swf",
		file_size_limit : "100 MB",
		file_types : "*.*",
		file_types_description : "所有文件",
		file_upload_limit : 1,
		file_queue_limit : 0,  
		file_post_name: "file", 
		
		button_text: '<span>选择文件</span>',
		button_width: "65",
		button_height: "29",
		button_placeholder_id : "spanSWFUploadButton",
		button_image_url:"<%=request.getContextPath()%>/js/swfupload/images/btn_bg.png",
		button_action : SWFUpload.BUTTON_ACTION.SELECT_FILE,
		debug:true,
		file_dialog_complete_handler : fileDialogComplete,
		upload_progress_handler:uploadProgress,
		upload_error_handler:uploadError,
		upload_success_handler:uploadSuccess
	});
}
</script>
</head>
<body>
	<s:form action="editDo" method="post">
		<s:hidden name="lesson.id"/>
		<s:hidden name="lesson.courseId"/>
		<table width="100%">
			<tr>
				<th>课时名称</th>
				<td>
					<s:textfield name="lesson.name"/>
				</td>
			</tr>
			<tr>
				<th>所属课程</th>
				<td>
					<s:textfield name="lesson.courseName" value="%{getCourseName(lesson.courseId)}" disabled="true"/>
				</td>
			</tr>
			<tr>
				<th>授课时长</th>
				<td>
					<s:textfield name="lesson.duration"/>(分)
				</td>
			</tr>
			<tr>
				<th>授课时间</th>
				<td>
					<s:textfield name="lesson.startTime"/>
				</td>
			</tr>
			<tr>
				<th>课时介绍</th>
				<td><s:textarea name="lesson.description"/>
				</td>
			</tr>
			<tr>
				<th>多媒体课件</th>
				<td><s:textfield name="lesson.coursewareMedia" id="mediaFile" readonly="true"/>
					<span id="spanSWFUploadButton">选择文件</span>
					<br/>
					<span style="width:200px;height:16px;line-height: 16px;display:block;border:1px #000000 solid;">
						<span id="progressBar1" style="width:0;height:16px;line-height: 16px;display:block;background-color: #ff0000;"></span>
					</span>
				</td>
			</tr>
			<tr>
				<th>文档课件</th>
				<td><s:textfield name="lesson.coursewareOffice"/>
				</td>
			</tr>
			<tr>
				<td colspan="2">
					<input type="submit" value="提交"/>
				</td>
			</tr>
		</table>
	</s:form>
</body>
<jsp:include page="/admin/jsp/common/errorMessage.jsp"/>
</html>